﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using mock_ehr_lib.Model.Summary;
using mock_ehr_web.Models;

namespace mock_ehr_web.Controllers
{
    public class SocialController : Controller
    {
        public ActionResult Create(string nqfNo)
        {
            var app = this.GetApp();
            var socialHistoryItem = new SocialHistoryItem
            {
               PatientID = app.CurrentPatient.ID
            };
            if(nqfNo == "0033")
            {
                socialHistoryItem.Description = "Cigarette consumption (observable entity)";
                socialHistoryItem.Value = "1 pack per day";
            }
            return PartialView("Create", socialHistoryItem);
        }
        public ActionResult Submit(SocialHistoryItem order)
        {
            var app = this.GetApp();
            var patientID = app.CurrentPatient.ID;
            order.PatientID = patientID;
            app.CurrentPatient.Summary.SocialHistory =
                app.CurrentPatient.Summary.SocialHistory.Union(new[] {order});
            return PartialView("Success", new SuccessModel
            {
                Message = "Social history item '" + order.Description + "' created successfully",
                ViewUrl = "#history"
            });
        }
    }
}
